export const USER_INFO_CACHE_KEY = 'userInfo'

export const setUserInfo = (data) => {
  wx.setStorageSync(USER_INFO_CACHE_KEY, data)
}

export const getUserInfo = () => {
  const userInfo =
    (wx.getStorageSync(USER_INFO_CACHE_KEY) ?? '') === ''
      ? null
      : wx.getStorageSync(USER_INFO_CACHE_KEY)
  return userInfo
}

export const clearUserInfo = () => {
  wx.removeStorageSync(USER_INFO_CACHE_KEY)
}
